// 引入swiper文件
$.getScript("./js/swiper.min.js");

// API
let footerNavBusinessUrl = "https://www.kcgeis.com/api/tBottomscope/list";
let footerNavCaseUrl = "https://www.kcgeis.com/api/tBottomshowcase/list";
let footerNavAboutUrl = "https://www.kcgeis.com/api/tBottomkcg/list";
let footerNavPersonUrl = "https://www.kcgeis.com/api/tBottomposition/list";
let footerNavContactUrl = "https://www.kcgeis.com/api/tContactsite/list";
let footerNavNewsUrl = "https://www.kcgeis.com/api/tBottomindustry/list";
let footerNavQrUrl = "https://www.kcgeis.com/api/tQr/list";
let aboutUrl = "https://www.kcgeis.com/api/tAbout/list";
let aboutPeopleUrl = "https://www.kcgeis.com/api/tAboutKernel/list";
let aboutBannerUrl = "https://www.kcgeis.com/api/tAboutTopbanner/list";
let aboutOfficeImgUrl = "https://www.kcgeis.com/api/tAboutWorkenvironment/list";
let newsUrl = "https://www.kcgeis.com/api/industry/list";
let phoneNavBusinessUrl = "https://www.kcgeis.com/api/tScopeBusiness/list";
let indexBannerUrl = "https://www.kcgeis.com/api/banner/list";
let caseClassListUrl = "https://www.kcgeis.com/api/tShowcaseCategory/list";
let personListUrl = "https://www.kcgeis.com/api/tPosition/list";
let contactFormUrl = "https://www.kcgeis.com/api/tOpinion/save";
let contactDidDataUrl = "https://www.kcgeis.com/api/demand/list";
let contactSidDataUrl = "https://www.kcgeis.com/api/software/list";
let contactCompanyUrl = "https://www.kcgeis.com/api/apiKcg/list";
let newsDetailUrl = "https://www.kcgeis.com/api/industry/selectOne";
let newsCategoryNavUrl = "https://www.kcgeis.com/api/apiIndustryCategory/list";
let caseDetailUrl = "https://www.kcgeis.com/api/tShowcase/selectOne";
let caseDetailMoreUrl = "https://www.kcgeis.com/api/tShowcaseCategory/selectOne"


// 咨询新闻分页


// 联系我们-公司信息
$.ajax({
    type: "GET",
    url: contactCompanyUrl,
    dataType: 'json',
    success: function(response) {
        let data = response.data;
        let comItem1 = "";
        for (let i = 0; i < data.length; i++) {
            comItem1 +=
                `
                <li class="contact-comItem">
                <p>${data[i]['title']}</p>
                <p>${data[i]['description']}</p>
                </li>
            `;
        }
        $('.contact-comList').html(comItem1)
    }
})


// 人才计划-点击获取数据
function clickPersonList(pid) {
    $.ajax({
        type: 'GET',
        url: personListUrl,
        dataType: "json",
        success: function(response) {
            let data = response.data;
            let personItem = "";
            $.each(data, function(index, obj) {
                if (obj.id == pid) {
                    personItem =
                        `<div class="person-postItem active" id="page${obj.id}">
                            <div class="person-postDuty">
                                <h1 class="person-dutyTitle">职位职责</h1>
                                <div class="person-dutyText">${obj.description}</div>
                            </div>
                            <div class="verticalLine"></div>
                            <div class="person-qualifications">
                                <h1 class="person-dutyTitle">任职资格</h1>
                                <div class="person-dutyText">${obj.descriptionss}</div>
                            </div>
                        </div>`

                    $('#personItem').html(personItem);
                }
            })

        }
    })
}
//新闻展示分类
$.ajax({
    type: 'GET',
    url: newsCategoryNavUrl,
    dataType: "json",
    success: function(response) {
        // console.log(response);

        let data = response.data;
        let newsNav = "";
        let newsItems = "";
        $.each(data, function(index, obj) {
            newsNav +=
                `<li class="page${index}" onclick="newsList(${obj.id},1,10)">
                    <p>${obj.name}</p>
                    <div class="redLine"></div>
                </li>`
            $('#newsNav').html(newsNav);
        })
    }
})


// 案例展示分类
$.ajax({
        type: 'GET',
        url: caseClassListUrl,
        dataType: "json",
        success: function(response) {
            let data = response.data;
            let caseNav = "";
            let caseItems = "";
            $.each(data, function(index, obj) {
                // 导航
                caseNav +=
                    `<li class="page${index}" onclick="clickCaseNav(${index})"><p>${obj.title}</p><div class="redLine"></div></li>`
                $('#caseNav').html(caseNav);
                // 默认显示导航第一个卡片
                if (index == 0) {
                    let firstNavList =
                        `<div class="grid-container caseOption active" id="page${obj.id}"><div class="row caseList"></div></div>`
                    $('#caseItems').html(firstNavList);
                    $.each(obj.apiTShowcases, function(id, item) {

                        caseItems +=
                            `<div class="caseItem">
                                <div class="caseCard">
                                    <a href="javascript:;" onclick="showCaseDetail(${item.id})">
                                        <img src="${item.showcaseThumbnail}">
                                    </a>
                                    <p class="caseCardText phone-hidden">${item.title}</p>
                                </div>
                            </div>`
                    })
                    $('#caseItems .caseList').html(caseItems);
                    $('#caseItems').append(firstNavList);
                }
                $('.caseNav .page' + navId).addClass('active');
                $('.caseNav .page' + navId).siblings().removeClass('active');

            })
        }
    })
    // 案例展示详情-点击对应卡片展示详情
function showCaseDetail(id) {
    // 跳转到案例详情页
    document.location.href = 'caseDetail.html?id=' + id;
}
// 案例展示详情-根据链接id加载内容
function loadCaseDetail(cid) {
    $.ajax({
            type: 'POST',
            url: caseDetailUrl,
            dataType: 'json',
            data: {
                id: cid
            },
            success: function(response) {
                let data = response.data
                let sid = data.sid
                    // analyzes为案例分析
                let Analyzes = data.apiShowcaseAnalyze;
                let analyzes = "";
                // Cores为核心功能
                let Cores = data.apiShowcaseCore;
                let cores = "";
                //Qr为演示二维码
                let Qr = data.apiDemonstrations;
                let qr = "";
                $('#cdProjectName').text(data.title)
                $('#cdCompanyName').text(data.companyName)
                $('#cdProjectBrief').html(data.projectTitle)
                $('.caseLeftBox img').attr('src', data.pic);
                // 加载案例分析
                for (let i = 0; i < Analyzes.length; i++) {
                    analyzes +=
                        `
                    <span class="hollowbg">${Analyzes[i].name}</span>
                `
                }
                $('.ShowcaseAnalyzes').html(analyzes);
                // 加载核心功能
                for (let i = 0; i < data.apiShowcaseCore.length; i++) {
                    cores +=
                        `
                    <span class="solidbg">${Cores[i].name}</span>  
                `
                }
                $('.ShowcaseCores').html(cores);

                //加载演示版二维码
                for (let i = 0; i < Qr.length; i++) {
                    qr +=
                        `
                        <div class="qrItem">
                        <i class="qrIcon"><img src="${Qr[i].ico}" alt=""></i>
                        <p class="qrtxt">${Qr[i].title}</p>
                        <i class="codeIcon"></i>
                        <div class="codeImg"><img src="${Qr[i].qr}" alt=""></div>
                    </div>
                `
                }
                $('.qrCode').html(qr);

                loadMoreCase(sid);
            }
        })
        // 上一页
    $.ajax({
        type: 'POST',
        dataType: 'json',
        url: caseDetailUrl,
        data: {
            sort: Number(cid) - 1
        },
        success: function(response) {
            let data = response.data
            $('.prevCase ~ .casePagTitle').text(data.title)
        }
    });
    // 下一页
    $.ajax({
        type: 'POST',
        dataType: 'json',
        url: caseDetailUrl,
        data: {
            sort: Number(cid) + 1
        },
        success: function(response) {
            let data = response.data
            $('.nextCase ~ .casePagTitle').text(data.title)
        }
    });

}
// 更多案例加载内容
function loadMoreCase(sid) {
    $.ajax({
        type: 'POST',
        url: caseDetailMoreUrl,
        data: {
            id: sid
        },
        success: function(response) {
            let data = response.data
            let moreCaseData = data.apiTShowcases;
            let content = "";
            if (moreCaseData.length <= 0) {
                content =
                    `<span>找不到当前案例分析</span>`
                $('.moreCase').html(content)
            } else if (moreCaseData.length > 0) {
                for (let i = 0; i < moreCaseData.length; i++) {
                    // 更多案例-每个案例最多加3个案例分析
                    content +=
                        `
                        <div class="moreCaseItem" id="moreCaseItem" onclick="loadCaseDetail(${moreCaseData[i].id})">
                            <img src="${moreCaseData[i].showcaseThumbnail}" alt="moreCaseImg" class="moreCaseDemoImg">
                            <p class="moreCase-t1">${data.title}</p>
                            <p class="moreCase-t2">
                                <span>${moreCaseData[i].title}</span>
                            </p>
                            <span class="floatR">></span>
                        </div>
                        `
                }
            }
            $('.moreCase').html(content)
        }
    })
}



// 案例展示-点击导航展示对应卡片
function clickCaseNav(navIndex) {
    console.log(navIndex);
    
    $.ajax({
            type: "GET",
            url: caseClassListUrl,
            dataType: "json",
            success: function(response) {
                let data = response.data;
                let caseItems = "";
                $.each(data, function(index, obj) {
                    if (index == navIndex) {
                        let caseList =
                            `<div class="grid-container caseOption active" id="page${obj.id}"><div class="row caseList"></div></div>`
                        $('#caseItems').html(caseList);
                        $.each(obj.apiTShowcases, function(id, item) {
                            caseItems +=
                                `<div class="caseItem">
                                <div class="caseCard">
                                    <a href="javascript:;" onclick="showCaseDetail(${item.id})">
                                        <img src="${item.showcaseThumbnail}">
                                            <p class="caseCardText phone-hidden">${item.title}</p>
                                    </a>
                                </div>
                            </div>`
                        })
                        $('#caseItems .caseList').html(caseItems);
                        $('#caseItems').append(caseList);
                    }
                })
            }
        })
        // 点亮点击的分类样式
    $('.caseNav .page' + navIndex).addClass('active');
    $('.caseNav .page' + navIndex).siblings().removeClass('active');
}


// 首页banner
$.ajax({
    type: 'GET',
    url: indexBannerUrl,
    dataType: "json",
    success: function(response) {
        let data = response.data;
        let indexBannerItem = "";
        $.each(data, function(index, obj) {
            let indexBanners =
                "<div class='swiper-slide'><picture></picture></div>"
            $('.indexBanner').html(indexBanners);
            let PCimg = `<img src="${obj.thumbnail}" alt="banner" style="width:100%;height:auto;">`
            $('.indexBanner picture').html(PCimg);


            $.each(obj.apiBanners, function(id, item) {
                console.log('asasas', id, item)
                let sourceNode = document.createElement('source');
                sourceNode.setAttribute('media', `(max-width:${item.name})`)
                sourceNode.setAttribute('srcset', item.thumbnail)
                if ($('.indexBanner picture')) {
                    $('.indexBanner picture').append($(sourceNode));
                }
            })
            indexBannerItem += $('.indexBanner').html();
            $('.indexBanner').html(indexBannerItem);
        })
    }
})


// 手机导航-业务范围
$.ajax({
        type: 'GET',
        url: phoneNavBusinessUrl,
        dataType: "json",
        success: function(response) {
            let data = response.data;
            let phoneNavBusiness = "";
            let pcNavBusiness = "";
            $.each(data, function(index, obj) {
                phoneNavBusiness +=
                    `<li><a href="${obj.url}">${obj.title}</a></li>`
                pcNavBusiness +=
                    `<li class="businessNavItem"><a href="${obj.url}">${obj.title}</a></li>`
                $('#phoneNav-business').html(phoneNavBusiness);
                $('#businessNav').html(pcNavBusiness);
            })
        }
    })
    // 底部-业务范围
$.ajax({
    type: "GET",
    url: footerNavBusinessUrl,
    dataType: "json",
    success: function(response) {
        let data = response.data;
        let businessList = "<li class='footer-title'>业务范围</li><li class='footerNavLine'></li>";
        $.each(data, function(index, obj) {
            businessList +=
                `<li><a href="${obj.link}">${obj.title}</a></li>`
            $('#footer-pc-business').html(businessList)
        })
    }
});
// 底部-案例展示
$.ajax({
    type: 'GET',
    url: footerNavCaseUrl,
    dataType: "json",
    success: function(response) {
        let data = response.data;
        let caseList = "<li class='footer-title'>案例展示</li><li class='footerNavLine'></li>";
        $.each(data, function(index, obj) {
            caseList +=
                `<li><a href="${obj.link}?navId=${index + 1}">${obj.title}</a></li>`
            $('#footer-pc-case').html(caseList);
            $('#phoneNav-case').html(caseList);
        })
    }
});
// 底部-关于空创格
$.ajax({
    type: 'GET',
    url: footerNavAboutUrl,
    dataType: "json",
    success: function(response) {
        let data = response.data;
        let aboutList = "<li class='footer-title'>关于空创格</li><li class='footerNavLine'></li>";
        $.each(data, function(index, obj) {
            aboutList +=
                `<li><a href="${obj.link}?point=po${index}">${obj.title}</a></li>`
            $('#footer-pc-about').html(aboutList);
            $('#phoneNav-about').html(aboutList);
        })
    }
});
// 底部-人才计划
$.ajax({
    type: 'GET',
    url: footerNavPersonUrl,
    dataType: "json",
    success: function(response) {
        let data = response.data;
        let personList = "<li class='footer-title'>人才计划</li><li class='footerNavLine'></li>";
        $.each(data, function(index, obj) {
            personList +=
                `<li><a href="${obj.link}">${obj.title}</a></li>`
            $('#footer-pc-person').html(personList);
            $('#phoneNav-person').html(personList);
        })
    }
});
// 底部-行业动态
$.ajax({
        type: 'GET',
        url: footerNavNewsUrl,
        dataType: "json",
        success: function(response) {
            let data = response.data;
            let newsList = "<li class='footer-title'>行业动态</li><li class='footerNavLine'></li>";
            $.each(data, function(index, obj) {
                newsList +=
                    `<li><a href="${obj.link}">${obj.title}</a></li>`
                $('#footer-pc-news').html(newsList);
                $('#phoneNav-news').html(newsList);
            })
        }
    })
    // 底部-联系我们
$.ajax({
        type: 'GET',
        url: footerNavContactUrl,
        dataType: "json",
        success: function(response) {
            let data = response.data[0];
            $('#footer-pc-comName').text(data.site);
            $('.footer-company').text(data.site);
            $('#footer-pc-phone').text(data.phone);
            // $('.gzhImg').attr('src', data.qr);
        }
    })
    // 底部二维码
$.ajax({
        type: "GET",
        url: footerNavQrUrl,
        dataType: "json",
        success: function(response) {
            let data = response.data;
            let QrUrl = "";
            for (let i = 0; i < data.length; i++) {
                QrUrl +=
                    `
                <div class="footer-contact-qr">
                    <img src="${data[i]['thumbnail']}" alt="公众号" class="gzhImg">
                    <span class="footer-gzh">${data[i]['name']}</span>
                </div>
                `
            }
            $('#footer-RQ').html(QrUrl);
        }

    })
    // 关于空创格
$.ajax({
    type: 'GET',
    url: aboutUrl,
    dataType: "json",
    success: function(response) {
        let data = response.data;
        $('.bi-title').text(data[0].title);
        $('.bi-text').text(data[0].description);
        $('.biItem > .bi-media').attr('src', data[0].video);
    }
});
// 关于空创格-人员介绍
$.ajax({
    type: 'GET',
    url: aboutPeopleUrl,
    dataType: "json",
    success: function(response) {
        let data = response.data;
        let peopleList = "";
        $.each(data, function(index, obj) {
            peopleList +=
                `<li class="staffItem">
                    <img src="${obj.kernelNThumbnail}" alt="head" class="staff-head">
                    <p class="staff-name">${obj.name}</p>
                    <p class="staff-job">${obj.position}</p>
                    <p class="staff-text">${obj.descriptions}</p>
                </li>`
            $('.staffList').html(peopleList);
        })

    }
});
// 关于空创格-banner
$.ajax({
    type: 'GET',
    url: aboutBannerUrl,
    dataType: "json",
    success: function(response) {
        let data = response.data;
        $('.aboutBanner source').attr('srcset', data[0].thumbnail)
        $('.aboutBanner img').attr('src', data[0].nthumbnail)
    }
});
// 关于空创格-办公环境4图
$.ajax({
        type: 'GET',
        url: aboutOfficeImgUrl,
        success: function(res) {
            let data = res.data
            let dataList = ""
            for (let i = 0; i < data.length; i++) {
                dataList +=
                    `<div class="item">
                <img src="${data[i].thumbnail}" alt="officeImg">
             </div>
            `
            }
            $('.environmentList').html(dataList)
        }
    })
    // 首页-新闻资讯获取4条数据
$.ajax({
        type: 'GET',
        url: newsUrl,
        data: {
            page: 1,
            size: 4
        },
        success: function(response) {
            let data = response.data.list
            let indexNewsLeft = ""; //左侧大图
            let indexNewsList = ""; //右侧三条数据
            indexNewsLeft =
                `
        <img src="${data[0].industryThumbnail}" alt="新闻图片" class="nai-img">
        <a href="newsDetail.html?id=${data[0].id}">
            <h1 class="nai-title textHiding-one">${data[0].title}</h1>
        </a>
        <div class="nai-text textHiding-two">${data[0].description}</div>
        
        `
            indexNewsLeft += `<a href="news.html" class="nai-button">查看更多新闻+</a>`
            $('.newsAndInformation .nai-newsDemo').html(indexNewsLeft)

            for (let i = 1; i < 4; i++) {
                indexNewsList +=
                    `
            <div class="nai-newsItem">
                <div class="nai-roundNum">
                    <p class="nai-listId">${i}</p>
                    <p class="nai-date">${data[i].createDate}</p>
                </div>
                <div class="nai-content">
                    <h1 class="nai-title textHiding-one">${data[i].title}</h1>
                    <div class="nai-text textHiding-one">${data[i].description}</div>
                    <a href="javascript:;" class="nai-more" onclick="newsDetail(${data[i].sort})">查看详情&nbsp;>></a>
                </div>
                
            </div>
            `
            }

            $('.newsAndInformation .nai-newsList').html(indexNewsList);
            // 首页新闻左侧内容

        }
    })
    // 热门动态内容
    // function loadNewsHeadlines(categoryId) {
    //     $.ajax({
    //         type: 'GET',
    //         url: newsUrl,
    //         data: {
    //             page: 1,
    //             size: 3,
    //             CategoryId: categoryId
    //         },
    //         success: function(res) {
    //             let data = res.data.list
    //             $('#newsHeadLeft .news-title').text(data[0].title)
    //             $('#newsHeadLeft .news-date').text(data[0].createDate)
    //             $('#newsHeadLeft .news-headText').text(data[0].describes)
    //             $('.news-headerBanner img').attr('src', data[0].industryThumbnail)

//             $('#newsHeadlines1 .news-boxTitle').text(data[1].title)
//             $('#newsHeadlines1 .news-boxContent').text(data[1].describes)
//             $('#newsHeadlines1 .record').text(" " + data[1].record)
//             $('#newsHeadlines1 .createDate').text(" " + data[1].createDate)

//             $('#newsHeadlines2 .news-boxTitle').text(data[2].title)
//             $('#newsHeadlines2 .news-boxContent').text(data[2].describes)
//             $('#newsHeadlines2 .record').text(" " + data[2].record)
//             $('#newsHeadlines2 .createDate').text(" " + data[2].createDate)
//         }
//     })
// }




// 行业动态
function newsList(categoryId, pageNum, size) {
    console.log(categoryId, pageNum, size);
    $.ajax({
        type: 'GET',
        url: newsUrl,
        data: {
            CategoryId: categoryId,
            page: pageNum,
            size: size
        },
        dataType: "json",
        success: function(response) {
            let data = response.data.list;
            console.log(data);
            let newsList = "";
            let newsHeaderBox = ""
            newsHeaderBox=`
            <li class="news-headerItem news-headerBanner" id="newsHeadLeft" onclick="newsDetail(${data[0].id})">
            <img src="${data[0].industryThumbnail}" alt="" class="news-headerBoxImg phone-hidden">
            <p class="news-title">${data[0].title}</p>
            <p class="news-date lg-hidden">${data[0].createDate}</p>
            <p class="news-headText">${data[0].describes}</p>
            <img src="${data[0].industryThumbnail}" alt="" class="news-headerBoxImg lg-hidden">
        </li>

        <li class="news-headerRight phone-hidden">
            <div class="news-headerRightBox" style="margin-bottom: 0.5rem;" id="newsHeadlines1" onclick="newsDetail(${data[1].id})">
                <p class="news-boxTitle">${data[1].title}</p>
                <p class="news-boxContent">${data[1].describes}</p>
                <span class="news-reads">
                    <img src="img/reads.png" alt=""><span class="record">${data[1].record}</span>
                </span>
                <span class="news-date">
                    <img src="img/date.png" alt=""><span class="createDate">${data[1].createDate}</span>
                </span>
            </div>
            <div class="news-headerRightBox" id="newsHeadlines2" onclick="newsDetail(${data[2].id})">
                <p class="news-boxTitle">${data[2].title}</p>
                <p class="news-boxContent">${data[2].describes}</p>
                <span class="news-reads">
                    <img src="img/reads.png" alt=""><span class="record">${data[2].record}</span>
                </span>
                <span class="news-date">
                    <img src="img/date.png" alt=""><span class="createDate">${data[2].createDate}</span>
                </span>
            </div>
        </li>`

            // $('#newsHeadlines1').click=newsDetail(data[1].id)
            // $('#newsHeadlines1 .news-boxTitle').text(data[1].title)
            // $('#newsHeadlines1 .news-boxContent').text(data[1].describes)
            // $('#newsHeadlines1 .record').text(" " + data[1].record)
            // $('#newsHeadlines1 .createDate').text(" " + data[1].createDate)

            // $('#newsHeadlines2 .news-boxTitle').text(data[2].title)
            // $('#newsHeadlines2 .news-boxContent').text(data[2].describes)
            // $('#newsHeadlines2 .record').text(" " + data[2].record)
            // $('#newsHeadlines2 .createDate').text(" " + data[2].createDate)


            $.each(data, function(index, obj) {
                if (index > 2) {
                    newsList +=
                        `<li class="news-bottomListItem" onclick="newsDetail(${obj.id})">
                        <a href="javascript:;">
                            <div class="leftImgBox">
                                <img src="${obj.industryThumbnail}" alt="newsImg">
                            </div>
                            <div class="news-bottomListItemMain">
                                <div class="news-phone-title">
                                    <span class="textHiding-one">${obj.title}</span>
                                    <span class="news-phone-date">浏览量：${obj.record}&nbsp&nbsp&nbsp&nbsp|&nbsp&nbsp&nbsp&nbsp ${obj.createDate}</span>
                                </div>
                                <div class="textHiding-four" id="newsListContent">${obj.describes}</div>
                                <p class="news-sss phone-hidden table-hidden"><img src="img/reads.png" alt=""> ${obj.record}</p>
                                <p class="news-sss phone-hidden table-hidden"><img src="img/date.png" alt=""> ${obj.createDate}</p>
                                <div class="news-details phone-hidden">查看详情</div>  
                            </div>
                        </a>
                    </li>`
                }


            })
            $('.news-headerBox').html(newsHeaderBox)
            $('.news-bottomList').html(newsList);
        }
    })

    $('.caseNav .page' + (categoryId - 1)).addClass('active');
    $('.caseNav .page' + (categoryId - 1)).siblings().removeClass('active');

    // 点亮当前分页按钮
    $('.news-pagesChange').find('#p' + pageNum).addClass('active');
    $('.news-pagesChange').find('#p' + pageNum).siblings().removeClass('active');

    //TODO: 预加载下一页内容，内容少于10个，只加载一个分页，等于10个，加载下一个分页
    $.ajax({
        type: 'GET',
        url: newsUrl,
        data: {
            CategoryId: categoryId,
            page: Number(pageNum) + 1,
            size: size
        },
        dataType: "json",
        success: function(response) {
            let data = response.data;
            if (data.list.length == 0) {
                // 下一页没有内容执行
                $('.news-pagesChange>.active').next().remove();
            } else {
                // 检测有内容则新增一分页
                let pageList = `<a href="javascript:;" onclick="newsList(${categoryId},${pageNum + 1},10)" id="p${pageNum + 1}">${pageNum + 1}</a>`
                if ($('.news-pagesChange>#p' + `${pageNum + 1}`).length > 0) {
                    // 这里已经有了下一分页
                    return false
                } else {
                    // 这里还没有下一分页，加上
                    $('.news-pagesChange').append(pageList);
                }
            }
        }
    })

}

//新闻动态展示-点击导航展示对应类别动态
// function clickNewsNav(categoryId, index) {
//     console.log(categoryId, index)
//     $.ajax({
//             type: 'GET',
//             url: newsUrl,
//             data: {
//                 CategoryId: categoryId,
//                 page: 1,
//                 size: 10
//             },
//             success: function(response) {
//                 let data = response.data.list;
//                 console.log(data);
//                 $.each(data, function(index, obj) {

//                     newsList +=
//                         `<li class="news-bottomListItem" onclick="newsDetail(${obj.id})">
//                             <a href="javascript:;">
//                                 <div class="leftImgBox">
//                                     <img src="${obj.industryThumbnail}" alt="newsImg">
//                                 </div>
//                                 <div class="news-bottomListItemMain">
//                                     <div class="news-phone-title">
//                                         <span class="textHiding-one">${obj.title}</span>
//                                         <span class="news-phone-date">浏览量：${obj.record}&nbsp&nbsp&nbsp&nbsp|&nbsp&nbsp&nbsp&nbsp ${obj.createDate}</span>
//                                     </div>
//                                     <div class="textHiding-four" id="newsListContent">${obj.describes}</div>
//                                     <p class="news-sss phone-hidden table-hidden"><img src="img/reads.png" alt=""> ${obj.record}</p>
//                                     <p class="news-sss phone-hidden table-hidden"><img src="img/date.png" alt=""> ${obj.createDate}</p>
//                                     <div class="news-details phone-hidden">查看详情</div>  
//                                 </div>
//                             </a>
//                         </li>`


//                     $('.news-bottomList').html(newsList);
//                 })
//             }
//         })
//         // 点亮点击的分类样式
//     $('.caseNav .page' + index).addClass('active');
//     $('.caseNav .page' + index).siblings().removeClass('active');
// }


// 行业动态-跳转详情
function newsDetail(pid) {
    // alert(pid);
    window.location.href = 'newsDetail.html?id=' + pid;
}

// 加载新闻详情内容
function loadNewsDetailData(nid) {
    // 按照链接id值加载内容
    $.ajax({
        type: "POST",
        dataType: "json",
        url: newsDetailUrl,
        data: {
            id: nid
        },
        success: function(response) {
            let data = response.data
            let labels = ""
            $('.newsDetailCou').text(data.record);
            $('.newsDetailRTitle').text(data.title);
            $('.newsDetailTime').text(data.createDate);
            // 新闻详情加载富文本内容
            $('#newsDetailContent').html(data.description);
            // 新闻详情标签
            $.each(data.apiLabels, function(index, item) {
                labels +=
                    `<span>${item.name}</span>`
            })
            $('.newsDetailLabels').html(labels)
        }
    });
    // 上一页
    $.ajax({
        type: 'POST',
        dataType: 'json',
        url: newsDetailUrl,
        data: {
            sort: Number(nid) - 1
        },
        success: function(response) {
            let data = response.data
            $('.newsDetailPagBtns .prevNewsTitle').text(data.title)
        }
    });
    // 下一页
    $.ajax({
        type: 'POST',
        dataType: 'json',
        url: newsDetailUrl,
        data: {
            sort: Number(nid) + 1
        },
        success: function(response) {
            let data = response.data
            $('.newsDetailPagBtns .nextNewsTitle').text(data.title)
        }
    });
    // 加载左侧导航栏
    $.ajax({
        type: 'GET',
        dataType: 'json',
        url: newsCategoryNavUrl,
        success: function(res) {
            let data = res.data
            let navList = ""
            $.each(data, function(index, item) {
                navList +=
                    `<a class="newsDetailNavs" href="news.html?id=${item.id}">${item.name}</a>`
            })
            $("#newsDetailNavList").html(navList)
        }
    })
}

// 联系我们获取did选项值
$.ajax({
        type: 'GET',
        dataType: "json",
        url: contactDidDataUrl,
        success: function(response) {
            let data = response.data;
            let didList = "<option value='' disabled selected hidden>服务类型</option>";
            $.each(data, function(index, obj) {
                didList +=
                    "<option value='" + obj.id + "'>" + obj.title + "</option>"
                $('#did').html(didList);
            })
        }
    })
    // 联系我们获取sid选项值
$.ajax({
    type: 'GET',
    dataType: "json",
    url: contactSidDataUrl,
    success: function(response) {
        let data = response.data;
        let sidList = "<option value='' disabled selected hidden>种类</option>";
        $.each(data, function(index, obj) {
            sidList +=
                "<option value='" + obj.id + "'>" + obj.title + "</option>"
            $('#sid').html(sidList);
        })
    }
})

//联系我们-表单封装上传
$('#submitBtn').click(function() {
    let arr = $('#contactForm').serializeArray();
    let obj = {}
    arr.forEach(item => {
        obj[item.name] = item.value
    })
    $.ajax({
        type: 'POST',
        dataType: 'json',
        url: contactFormUrl,
        contentType: 'application/json',
        data: JSON.stringify(obj),
        success: function(res) {
            if (res.status == 200) {
                alert('感谢您的留言');
            }
        },
        error: function(err) {
            alert(err.msg);
        }
    });
    return false
});